//
//  TicketInforTipCell.m
//  ImGuider
//
//  Created by 王鹏宇 on 2018/1/3.
//  Copyright © 2018年 imguider. All rights reserved.
//

#import "TicketInforTipCell.h"
#import "TicketTipListCell.h"
@implementation TicketInforTipCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"TicketTipListCell" bundle:nil] forCellReuseIdentifier:@"TicketTipListCell"];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.tableView.scrollEnabled = NO;
    self.tableViewH.constant = 120;
    
}

- (NSDictionary *)getTicketUsetimeWith:(TicketDetailModel *)model {
    
    NSMutableDictionary * dict = [NSMutableDictionary new];
    [dict setValue:@(3) forKey:@"type"];
    
    NSString * str = MYLocalizedString(@"TICKET_USE_DATE_TIP", nil);
    if ([model.usetime isEqualToString:@"date"]) {
        
       [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_USE_DATE_WITH_DAY", nil)] forKey:@"desc"];
    }else if([model.usetime isEqualToString:@"time"]){
        [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_USE_DATE_WITH_TIME", nil)] forKey:@"desc"];
    }else{
    
        [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_USE_DATE_ALL", nil)] forKey:@"desc"];
    }
    
    
    return dict;
}

- (NSDictionary *)getTicketWayWith:(TicketDetailModel *)model {
    
    NSMutableDictionary * dict = [NSMutableDictionary new];
    [dict setValue:@(2) forKey:@"type"];
    
    NSString * str = MYLocalizedString(@"TICKET_COLLECTION_METHOD_WAY", nil);
    if ([model.ticketway isEqualToString:@"passport"]) {
        
       [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_COLLECTION_METHOD_PASSPORT", nil)] forKey:@"desc"];
    }else{
       [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_COLLECTION_METHOD_ETICKET", nil)] forKey:@"desc"];
    }
    
    
    return dict;
}
- (NSDictionary *)getIntoWayWith:(TicketDetailModel *)model {
    
    NSMutableDictionary * dict = [NSMutableDictionary new];
    [dict setValue:@(4) forKey:@"type"];
    
    NSString * str = MYLocalizedString(@"TICKET_USE_TYPE", nil);
    if ([model.ticketway isEqualToString:@"passport"]) {
        
        [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_USE_TYPE_PASSPORT", nil)] forKey:@"desc"];
    }else{
        [dict setValue:[str stringByAppendingString:MYLocalizedString(@"TICKET_USE_TYPE_ETICKET", nil)] forKey:@"desc"];
    }
    
    
    return dict;
}

- (void)setTDmodel:(TicketDetailModel *)TDmodel {
    
    _TDmodel = TDmodel;
    if (TDmodel.entityticket.boolValue) {
        self.tableViewH.constant = 120;
        self.tipLists =[NSMutableArray arrayWithArray:@[@{@"type":@(1),@"desc":MYLocalizedString(@"TICKET_REFUND_POLICY_NO", nil)}]];
        
        [self.tipLists addObject:[self getTicketWayWith:TDmodel]];
        [self.tipLists addObject:[self getTicketUsetimeWith:TDmodel]];
        [self.tipLists addObject:[self getIntoWayWith:TDmodel]];
        
    }else{
        self.tableViewH.constant = 90;
        self.tipLists =[NSMutableArray arrayWithArray:@[@{@"type":@(1),@"desc":MYLocalizedString(@"TICKET_REFUND_POLICY_NO", nil)}]] ;
        
        [self.tipLists addObject:[self getTicketUsetimeWith:TDmodel]];
        [self.tipLists addObject:[self getIntoWayWith:TDmodel]];
    }
    
    [self.tableView reloadData];
}






#pragma mark     -- UITableViewDelegate,UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.tipLists.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TicketTipListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TicketTipListCell"];
    
    NSDictionary * dict = self.tipLists[indexPath.row];
    
    [cell configWithDict:dict];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 30;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
